<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class model_baigiang extends CI_Model
{
    public function __construct() {
        parent::__construct();
    }
    
    public function laythongtinbaigiang() {
		$this->db->select('*');
		$this->db->from('baigiang');
		$this->db->join('monhoc', 'monhoc.mamonhoc = baigiang.mamonhoc');
		$this->db->join('giaovien', 'giaovien.magiaovien = baigiang.magiaovien');

		$query = $this->db->get();
		return $query->result();
	}

	public function laybaitap() {
		$this->db->select('*');
		$this->db->from('baitap');

		$query = $this->db->get();
		return $query->result();
	}

	public function timbaigiang($monhoc, $lop, $tengiaovien) {
		$this->db->select('*');
		$this->db->from('baigiang');
		$this->db->join('monhoc', 'monhoc.mamonhoc = baigiang.mamonhoc');
		$this->db->join('giaovien', 'giaovien.magiaovien = baigiang.magiaovien');
		
		$this->db->like('monhoc.tenmonhoc', $monhoc); 
		$this->db->like('monhoc.khoi', $lop);
		$this->db->like('giaovien.hoten', $tengiaovien);

		$query = $this->db->get();
		return $query->result();
	}
}